﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using Telerik.Web.UI;
using KPIS.GERP.GIMS.DAL;
using KPIS.GERP.GIMS.MODEL;
using System.Collections.Generic;

namespace KPIS.GERP.GIMS.APP.APP_UI.Form
{
    public partial class ICM_Inventory_Control : System.Web.UI.Page
    {
        Common.Main cn = new Common.Main();
        D_IcmInventoryControl d_inventory = new D_IcmInventoryControl();
        M_IcmInventoryControl m_inventory = new M_IcmInventoryControl();
        D_IcmMasResourceItem d_resource_item = new D_IcmMasResourceItem();
        M_IcmMasResourceItem m_resource_item = new M_IcmMasResourceItem();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadGrid();
               // grdInventoryControl.DataBind();
            }
        }
        protected void cmbInventoryCode_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            string strFilter = e.Text;
            IList<M_IcmMasResourceItem> infoList = d_resource_item.GetListFillByName(strFilter);
            int itemOffset = e.NumberOfItems;
            int endOffset = Math.Min(itemOffset + 10, infoList.Count);
            e.EndOfItems = endOffset == infoList.Count;

            for (int i = itemOffset; i < endOffset; i++)
            {
                cmbInventoryCode.Items.Add(new RadComboBoxItem(infoList[i].icm_code_name, infoList[i].icm_res_item_seq.ToString()));
            }

            e.Message = cn.GetStatusMessage(endOffset, infoList.Count);
        }
        protected void grdInventoryControl_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            LoadGrid();
        }
        private void LoadGrid()
        {
            grdInventoryControl.DataSource = d_inventory.GetList();
        }
    }
}
